package org.suwenqian.audiovideosummary.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.suwenqian.audiovideosummary.result.Result;
import org.suwenqian.audiovideosummary.service.QiNiuUploadService;
import org.suwenqian.audiovideosummary.web.Results;

import java.io.IOException;

@RestController
@RequiredArgsConstructor
@RequestMapping("/audio-video")
public class QiNiuUploadController {

    private final QiNiuUploadService qiNiuUploadService;

    /**
     * 上传音视频文件
     * @param file 文件
     * @return 返回上传的后的 key 值
     * @throws IOException 抛出异常
     */
    @PostMapping("/uploadQiNiu")
    public Result<String> uploadQiNiu(@RequestPart("file") MultipartFile file) throws IOException {
        return Results.success(qiNiuUploadService.uploadQiNiu(file));
    }



}
